package com.songtai.action.admin.node;

import java.io.PrintWriter;
import java.util.List;

import net.sf.json.JSONArray;

import com.songtai.action.SongtaiActionSupport;
import com.songtai.pojo.NodeView;
import com.songtai.service.NodeService;

/**
 * @author 赵中杨
 * @email zhaozhongyang717@gmail.com
 * @date 2010 2010-4-19 上午10:26:23
 */
public class NodeAction extends SongtaiActionSupport {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = -7428606406567506904L;
	private static final String CONTENT_TYPE = "text/html; charset=utf-8";
	private Long nodeid;
	private NodeService nodeService;
	private List<NodeView> nodes;

	@Override
	public String execute() throws Exception {
		response.setContentType(CONTENT_TYPE);
		PrintWriter out = response.getWriter();
		nodes = nodeService.getChildren(nodeid);
		if (nodes != null && !nodes.isEmpty()) {
			out.print(JSONArray.fromObject(nodes));
		} else {
			out.print("");
		}
		return null;
	}


	/**
	 * @return the nodeid
	 */
	public Long getNodeid() {
		return nodeid;
	}


	/**
	 * @param nodeid the nodeid to set
	 */
	public void setNodeid(Long nodeid) {
		this.nodeid = nodeid;
	}


	/**
	 * @return the nodes
	 */
	public List<NodeView> getNodes() {
		return nodes;
	}

	/**
	 * @param nodes
	 *            the nodes to set
	 */
	public void setNodes(List<NodeView> nodes) {
		this.nodes = nodes;
	}

	/**
	 * @return the nodeService
	 */
	public NodeService getNodeService() {
		return nodeService;
	}

	/**
	 * @param nodeService
	 *            the nodeService to set
	 */
	public void setNodeService(NodeService nodeService) {
		this.nodeService = nodeService;
	}

}
